Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-3658: JWST Accommodation of the Ramp Fitting Likelihood Algorithm #8631

Merged
merged 10 commits into from
Sep 19, 2024

Conversation

kmacdonald-stsci
Copy link
Contributor

Resolves JP-3658

Closes #

This PR addresses the use of the likelihood algorithm with ramp fitting. This updates the spec for the arguments of ramp fitting to allow for LIKELY as an algorithm option. Also, the detector1 pipeline is modified to do some special handling needed when using the likelihood algorithm. In particular, there data needs at least 4 groups per integration and, since the likelihood algorithm does its own jump detection, the normal pipeline jump detection needs to be skipped when using the likelihood algorithm.

Checklist for PR authors (skip items if you don't have permissions or they are not applicable)

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • All comments are resolved
  • Make sure the JIRA ticket is resolved properly

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 61.75%. Comparing base (5783cfb) to head (9c55a0a).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
jwst/ramp_fitting/ramp_fit_step.py 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8631      +/-   ##
==========================================
- Coverage   61.75%   61.75%   -0.01%     
==========================================
  Files         377      377              
  Lines       38750    38755       +5     
==========================================
+ Hits        23931    23934       +3     
- Misses      14819    14821       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@melanieclarke melanieclarke changed the title JP_3658: JWST Accommodation of the Ramp Fitting Likelihood Algorithm JP-3658: JWST Accommodation of the Ramp Fitting Likelihood Algorithm Sep 3, 2024
Copy link
Collaborator

@melanieclarke melanieclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to wait until the stcal PR is merged:
spacetelescope/stcal#278

In the meantime, a few comments on the structure and log messages here. Also, we'll need to update the documentation here, to match the changes in stcal and add the new option for the algorithm argument.

jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@melanieclarke melanieclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more small tidy-up comments

CHANGES.rst Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
jwst/pipeline/calwebb_detector1.py Outdated Show resolved Hide resolved
@melanieclarke
Copy link
Collaborator

Looking better, thanks! It looks like we still need documentation updates for the ramp fit step, though.

@melanieclarke
Copy link
Collaborator

Testing on some real data with ngroups=3, it looks like it warns and switches to OLS_C correctly when the step is called from the detector1 pipeline. When ramp_fit is called directly, though, it reports Using algorithm = LIKELY, but then the step unexpectedly succeeds -- it looks like it's quietly defaulting to OLS (python) instead. It should warn and default to OLS_C.

Sorry for the late realization, but since we are no longer turning off jump detection by default, perhaps this check should actually just be moved from the detector1 pipeline to the ramp fit step instead, so we can handle both calling conditions in the same place.

… the detector1 pipeline to handle any problems that can be encountered using the likelihood algorithm.
… automatically skipping the normal pipeline jump detection algorithm.
@melanieclarke
Copy link
Collaborator

@kmacdonald-stsci - coming back to this one, now that the stcal PR is close to ready. Can we move the check for ngroups into the ramp_fit step and add some likelihood documentation?

@kmacdonald-stsci
Copy link
Contributor Author

@kmacdonald-stsci - coming back to this one, now that the stcal PR is close to ready. Can we move the check for ngroups into the ramp_fit step and add some likelihood documentation?

If you want the NGROUPS check moved to the step code, then it can probably just be moved to STCAL, so the only change for this PR will be the addition of the LIKELY option to the algorithm parameter.

@melanieclarke
Copy link
Collaborator

If you want the NGROUPS check moved to the step code, then it can probably just be moved to STCAL, so the only change for this PR will be the addition of the LIKELY option to the algorithm parameter.

It looks to me like the ramp_fit_step interface in jwst reports the algorithm it's going to use before it calls the stcal code, so it would be nice to have the check there, before that happens. We will also need the documentation updates on the jwst side.

Comment on lines 421 to 424
log.info(f"When selecting the LIKELY ramp fitting algorithm the"
" ngroups needs to be a minimum of {likely_fit.LIKELY_MIN_NGROUPS},"
" but ngroups = {ngroups}. Due to this, the ramp fitting algorithm"
" is being changed to OLS_C")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is long - let's split it up into two messages and make them warnings. Also, the f needs to go at the front of all the substrings to get the variables in there properly.

Suggested change
log.info(f"When selecting the LIKELY ramp fitting algorithm the"
" ngroups needs to be a minimum of {likely_fit.LIKELY_MIN_NGROUPS},"
" but ngroups = {ngroups}. Due to this, the ramp fitting algorithm"
" is being changed to OLS_C")
log.warning(f"When selecting the LIKELY ramp fitting algorithm the"
f" ngroups needs to be a minimum of {LIKELY_MIN_NGROUPS},"
f" but ngroups = {ngroups}.")
log.warning("Due to this, the ramp fitting algorithm"
" is being changed to OLS_C.")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the variable reference. Can you please also add the f at the beginning of the substrings, so the variables are printed properly? Also, split into two messages and make it a warning instead of an info.

@tapastro
Copy link
Contributor

tapastro commented Sep 19, 2024

EDIT: Scratch that, pin suggestion being taken care of in separate PR. I think I can take it from here.

@tapastro tapastro marked this pull request as ready for review September 19, 2024 20:04
@tapastro tapastro requested a review from a team as a code owner September 19, 2024 20:04
@tapastro tapastro merged commit f712e76 into spacetelescope:master Sep 19, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants